package com.spa.infrastructure.repository.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.spa.domain.entity.MsgAlarmLog;
import com.spa.infrastructure.mapper.MsgAlarmLogMapperStruct;
import com.spa.infrastructure.repository.condition.MsgAlarmLogCondition;
import com.spa.infrastructure.repository.mapper.MsgAlarmLogMapper;
import com.spa.infrastructure.repository.po.MsgAlarmLogPO;
import com.spa.infrastructure.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * domain service
 * (MsgAlarmLog) 
 *
 * @author makejava
 * @since 2024-01-11 11:34:32
 */
@Component
public class MsgAlarmLogRepositoryService extends MPJBaseServiceImpl<MsgAlarmLogMapper, MsgAlarmLogPO> {

    @Autowired
    private MsgAlarmLogMapper MsgAlarmLogMapper;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    public MsgAlarmLogPO queryById(Long id) {
		return getById(id);
    }
	
	
	/**
     * 分页查询
     * @return 查询结果
     */
	public Page<MsgAlarmLogPO> pageListInfo(MsgAlarmLogCondition condition) {
	
		LambdaQueryWrapper<MsgAlarmLogPO> wrapper = wrapper(condition);
        return page(Page.of(condition.getCurrent(), condition.getSize()), wrapper);

    }
	
	public List<MsgAlarmLogPO> listInfo(MsgAlarmLogCondition condition) {
        return list(wrapper(condition));

    }
	
	
	private LambdaQueryWrapper<MsgAlarmLogPO> wrapper(MsgAlarmLogCondition condition) {
        LambdaQueryWrapper<MsgAlarmLogPO> wrapper = Wrappers.lambdaQuery(); 
        return wrapper;
    }


    public int add(MsgAlarmLog po) {
        MsgAlarmLogPO MsgAlarmLogPO = MsgAlarmLogMapperStruct.INSTANCE.entity2Po(po);
        MsgAlarmLogPO.setCreateBy(SessionUtil.getUser().getExtUserId());
        MsgAlarmLogPO.setCreateTime(new Date());
        return MsgAlarmLogMapper.insert(MsgAlarmLogPO);
    }






}
